package caiziyou.com.designpattern.principle.singleresponbility;

/**
 * 设计模式设计原则之单一职责原则
 * 
 * @author Administrator
 *
 */
public class SingleResponsibility2 {
	public static void main(String[] args) {
		RoadVehicle vehicle = new RoadVehicle();
		vehicle.run("自行车");
		vehicle.run("汽车");
		vehicle.run("摩托车");
		
		AirVehicle vehicle1 = new AirVehicle();
		
		vehicle1.run("飞机");
	}
}

/**
 * 开销比较大需要改源码同时需要修改客户端
 *
 */
class RoadVehicle {
	public void run(String vehicle) {
		System.out.println(vehicle + "在公路上跑。。。");
	}
}

class AirVehicle {
	public void run(String vehicle) {
		System.out.println(vehicle + "在天上飞。。。");
	}
}

class WaterVehicle {
	public void run(String vehicle) {
		System.out.println(vehicle + "在水中游。。。");
	}
}